<template>
  <div class="upload-box">
    <div class="upload-item">
      <div class="item-title">1.默认上传列表:</div>
      <div>
        <CloudUpload
          name="image"
          accept="image"
          :multiple="true"
          action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
          :headers="headers"
          @change="handleChange"
        >
        </CloudUpload>
      </div>
    </div>
    <div class="upload-item" style="margin-top: 16px">
      <div class="item-title">2.上传列表云设计(isDesignUpload=true):</div>
      <div>
        <CloudUpload
          :isDesignUpload="true"
          name="file"
          :multiple="true"
          action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
          :headers="headers"
          :showUploadList="false"
          @change="handleChange"
        >
        </CloudUpload>
      </div>
    </div>
    <div style="margin-top: 16px" class="upload-item">
      <div class="item-title">3.云设计拖拽不展示拖动进度showUploadList=false</div>
      <div>
        <CloudUploadDragger
          name="file"
          :defaultSize="1"
          :showUploadList="false"
          action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
        >
        </CloudUploadDragger>
      </div>
    </div>
    <div style="margin-top: 16px" class="upload-item">
      <div class="item-title">4.云设计拖拽展示拖动进度showUploadList=true显示多个</div>
      <div>
        <CloudUploadDragger
          name="file"
          :defaultSize="1"
          :showUploadList="true"
          :fileType="fileType0"
          defaultFileFormatTip="将任意格式文件（且文件不超过1MB）拖拽到此处"
          action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
        >
        </CloudUploadDragger>
      </div>
    </div>
    <div style="margin-top: 16px" class="upload-item">
      <div class="item-title">5.商城拖拽(isDesignUploadDragger=false),设置defaultFileFormatTip自定义文件格式提示):</div>
      <div class="upload-box4">
        <CloudUploadDragger
          name="file"
          :defaultSize="1"
          :showUploadList="true"
          :isDesignUploadDragger="false"
          defaultFileFormatTip="支持扩展名：.xls .ppt .pptx .doc .docs .pdf .jpg"
          :fileType="fileType"
          action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
        >
        </CloudUploadDragger>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  title: '1.基础用法(文件上传)',
  subTitle: '经典款式，用户点击按钮弹出文件选择框。',
  data() {
    return {
      fileName: '',
      uploadStatus: null,
      uploadLoading: false,
      isShowList: false,
      currentPercent: 0,
      fileType0: ['*'],
      fileType: ['xls', 'ppt','pptx', 'doc', 'docs', 'pdf', 'jpg'],
      headers: {
        authorization: 'authorization-text',
      },
    }
  },
  methods: {
    handleChange(info) {
      console.log('info-0-------', info)

      if (info.file.status !== 'uploading') {
        console.log(info.file, info.fileList);
      }
      if (info.file.status === 'done') {
        this.$message.success(`${info.file.name} file uploaded successfully`);
      } else if (info.file.status === 'error') {
        this.$message.error(`${info.file.name} file upload failed.`);
      }
    },

    handleChange1(info) {
      this.uploadLoading = (info.file.status === 'uploading')
      if (info.file.status !== 'uploading') {
        console.log(info.file, info.fileList);
      }
      if (info.file.status === 'done') {
        this.$message.success(`${info.file.name} file uploaded successfully`);
      } else if (info.file.status === 'error') {
        this.$message.error(`${info.file.name} file upload failed.`);
      }
    },

    remove() {
      this.isShowList = false
    }
  }
}
</script>

<style lang="scss">
// .cloud-upload {
//   .cloud-button.ant-btn-default:hover,
//   .cloud-button.ant-btn-default:focus {
//     color: #007aff;
//     border-color: #007aff;
//   }
// }
// .upload-box {
//   .upload-item {
//     display: flex;
//     align-items: center;
//   }
// }
// .custom-upload-list-header {
//   display: flex;
// }
.item-title {
  padding-bottom: 8px;
}
</style>
